package com.neuedu.autosale.purchase.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.neuedu.autosale.entity.Pager;
import com.neuedu.autosale.entity.Result;

import com.neuedu.autosale.mapper.StockMapper;
import com.neuedu.autosale.purchase.entity.Stock;
import com.neuedu.autosale.purchase.service.StockService;


@Service
@Transactional
public class StockServiceImpl implements StockService{

	@Autowired
	private StockMapper stockMapper;

	@Override
	public List<Stock> findListByPager(Pager<Stock> pager) {
		return stockMapper.findListBypager(pager);
	}

	@Override
	public Integer findTotalByPager(Pager<Stock> pager) {
		return stockMapper.findTotalByPager(pager);
	}

	@Override
	public Result add(Stock object) {
		Result result = new Result(false, "新增失败！");
		boolean ret = stockMapper.add(object);
		if (ret) {
			result = new Result(true, "新增成功！");
		}
		return result;
	}

	@Override
	public Result edit(Stock object) {
		Result result = new Result(false, "修改失败！");
		boolean ret = stockMapper.edit(object);
		if (ret) {
			result = new Result(true, "修改成功！");
		}
		return result;
	}

	@Override
	public Result deleteByIds(List<Stock> ids) {
		Result result = new Result(false, "删除失败！");
		boolean ret = stockMapper.deleteByIds(ids);
		if (ret) {
			result = new Result(true, "删除成功！");
		}
		return result;
	}

	@Override
	public List<Stock> findAll() {
		return stockMapper.findAll();
	}
	
	
	
}
